-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Update image handling #14564
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update image handling #14564
Conversation
Co-authored-by: paul.jaffre <[email protected]>
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Bundle ReportChanges will increase total bundle size by 91.16kB (0.4%) ⬆️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: sentry-docs-client-array-pushAssets Changed:
Files in
view changes for bundle: sentry-docs-server-cjsAssets Changed:
Files in
Files in
Files in
App Routes Affected:
|
Co-authored-by: paul.jaffre <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the 🤖 is almost there! 😅
{shouldUseNextImage && dimensions ? ( | ||
<Image | ||
src={getImageUrl(src, imgPath)} | ||
alt={alt} | ||
width={dimensions.width} | ||
height={dimensions.height} | ||
className="max-h-[90vh] max-w-[90vw] object-contain" | ||
style={{ | ||
width: 'auto', | ||
height: 'auto', | ||
}} | ||
priority | ||
{...imageCompatibleProps} | ||
/> | ||
) : ( | ||
/* eslint-disable-next-line @next/next/no-img-element */ | ||
<img | ||
src={getImageUrl(src, imgPath)} | ||
alt={alt} | ||
loading="lazy" | ||
decoding="async" | ||
className="max-h-[90vh] max-w-[90vw] object-contain" | ||
style={{ | ||
width: 'auto', | ||
height: 'auto', | ||
}} | ||
{...props} | ||
/> | ||
)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we pass a isInline
boolean to renderImage
and then add classNAme if not? otherwise it's very similar to the function above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call
}; | ||
|
||
return ( | ||
<Dialog.Root open={open} onOpenChange={setOpen}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would still abstract Dialog
or call it Lightbox
as it's own reusable component similar to ShadCN https://ui.shadcn.com/docs/components/dialog to consume in here.
return ( | ||
<Dialog.Root open={open} onOpenChange={setOpen}> | ||
{/* Custom trigger that handles modifier keys properly */} | ||
<div |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have you tried using Dialog.Trigger
? I think that would eliminate the need for custom onClick / keydown handling and would do semantics / accessibility for us?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Things were getting wonky with the intended behavior and needed some custom event handling but things have changed a bit since then. I'll see if we can't lean on this now
<div | ||
onClick={handleModifierClick} | ||
onKeyDown={handleModifierKeyDown} | ||
onClick={handleClick} | ||
onAuxClick={handleClick} | ||
onKeyDown={handleKeyDown} | ||
className="cursor-pointer border-none bg-transparent p-0 block w-full no-underline" | ||
aria-label={`View image: ${alt}`} | ||
role="button" | ||
tabIndex={0} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i dont think it needs this (apart from aira-label) because https://github.com/radix-ui/primitives/blob/main/packages/react/dialog/src/dialog.tsx#L105-L107 handles it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh nice. Less code is the best code! I still need some of it for the modifier logic but can pull some off
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup and you can put all that on the <Dialog.Trigger />
directly and remove the asChild
prop
Co-authored-by: Sergiy Dybskiy <[email protected]>
9200f86
to
5dc9bcd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<Lightbox.Root open={open} onOpenChange={setOpen} content={renderImage(false)}> | ||
<Lightbox.Trigger | ||
onClick={handleClick} | ||
onAuxClick={handleClick} | ||
onKeyDown={handleKeyDown} | ||
className="cursor-pointer border-none bg-transparent p-0 block w-full no-underline" | ||
aria-label={`View image: ${alt}`} | ||
> | ||
{renderImage()} | ||
</Lightbox.Trigger> | ||
</Lightbox.Root> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice
DESCRIBE YOUR PR
This PR implements a modern image lightbox for all documentation images, enhancing the user experience.
Previously, clicking an image would open the raw image file in a new browser tab. This change introduces an in-page modal overlay for images, leveraging Radix UI Dialog for accessibility and a smooth user experience.
Key features:
IS YOUR CHANGE URGENT?
Help us prioritize incoming PRs by letting us know when the change needs to go live.
SLA
Thanks in advance for your help!
PRE-MERGE CHECKLIST
Make sure you've checked the following before merging your changes:
LEGAL BOILERPLATE
Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.
EXTRA RESOURCES